import { getSerachList } from 'api/search'
const state = {
  searchList: {}
}
const mutations = {
  // 设置搜索出来的商品
  setSerachList (state, payload) {
    state.searchList = payload
  }
}
const actions = {
  // 搜索出来的数据
  async ongetSerachList ({ commit }, data = {}) {
    const { data: res } = await getSerachList(data)
    commit('setSerachList', res.data)
  }
}
const getters = {
  // 商品信息
  goodsList (state) {
    return state.searchList.goodsList || []
  },
  // 属性信息
  attrsList (state) {
    return state.searchList.attrsList || []
  },
  // 品牌信息
  trademarkList (state) {
    return state.searchList.trademarkList || []
  },
  // 搜索页面商品总数
  searchListTotal (state) {
    return state.searchList.total || 0
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
